import { useEffect, useState } from "react";
import { CreatePops, createOrUpdateData } from "../type/active";
import { message } from "antd";

export const useCreate = (props: CreatePops) => {
  const [params, setParams] = useState<any>({});
  useEffect(() => {
    if (JSON.stringify(params) !== "{}") {
      createDeflate();
    }
  }, [params]);
  const createDeflate = async () => {
    // 按着业务逻辑 新增和编辑应该是一个接口 只是根据有没有id来区分
    const result: any = await props.API(params);
    message.success(result.message);
  }
  return {
    setParams,
  };
};
